﻿<Window
    x:Class="MVVMAppIDataErrorInfo.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Height="364"
    Width="515"
    Title="MVVM Survival Guide"
    DataContext="{Binding Main, Source={StaticResource Locator}}">    
    
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Skins/MainSkin.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>

    <Grid x:Name="LayoutRoot">        
        <Grid.RowDefinitions>
            <RowDefinition Height="50" />
            <RowDefinition Height="auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid Grid.Row="0" Background="Navy">
            <TextBlock FontSize="24"
                   FontWeight="Bold"
                   Foreground="White"                   
                   Text="Equipment Running Hours"
                   VerticalAlignment="Center"
                   HorizontalAlignment="Center"
                   TextWrapping="Wrap" />
        </Grid>                
        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="0.25*" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="auto" />
                <RowDefinition Height="auto" />
                <RowDefinition Height="auto" />
                <RowDefinition Height="auto" />
                <RowDefinition Height="auto" />                
            </Grid.RowDefinitions>
            <Label Content="Equipment" Grid.Column="0" Grid.Row="0" 
                    Margin="5,5,5,5"/>
            <TextBox Text="{Binding Equipment, ValidatesOnDataErrors=True}"
                     Margin="5,5,5,5" Grid.Column="1" Grid.Row="0" />
            <Label Content="Running Hours" Grid.Column="0" Grid.Row="1" 
                    Margin="5,5,5,5"/>
            <TextBox Margin="5,5,5,5" Grid.Column="1" Grid.Row="1">
                <TextBox.Text>
                    <Binding Path="RunningHours">
                        <Binding.ValidationRules>
                            <DataErrorValidationRule  />
                        </Binding.ValidationRules>
                    </Binding>
                </TextBox.Text>
            </TextBox>
            <Label Content="Operator" Grid.Column="0" Grid.Row="2" 
                    Margin="5,5,5,5"/>
            <TextBox 
                Text="{Binding EquipmentOperator, ValidatesOnDataErrors=True}" 
                Margin="5,5,5,5" Grid.Column="1" Grid.Row="2" />
            <Label Content="Supervisor" Grid.Column="0" Grid.Row="3" 
                    Margin="5,5,5,5"/>
            <TextBox 
                Text="{Binding ShiftSupervisor, ValidatesOnDataErrors=True}" 
                Margin="5,5,5,5" Grid.Column="1" Grid.Row="3" />
            <Button Content="Log Running Hours" Grid.Row="4" 
                    Margin="5,5,5,5" Grid.Column="1" 
                    HorizontalAlignment="Left" Padding="4,4,4,4" 
                    Command="{Binding LogRunningHoursCommand}"/>
        </Grid>        
        <Grid Grid.Row="2" >
            <TextBlock Text="{Binding Error}" 
                       Margin="5,5,5,5"
                       TextWrapping="Wrap"/>
        </Grid>
    </Grid>
</Window>
